package riceSystem.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import riceSystem.dao.DaoTemplateInterface;
import riceSystem.entity.Message;
import riceSystem.exception.RunException;
import riceSystem.service.ServiceTemplateInterface;
@Component("messageService")
public class MessageServiceImpl implements ServiceTemplateInterface<Message> {
	
	private DaoTemplateInterface<Message> messageDao;
	
	public DaoTemplateInterface<Message> getMessageDao() {
		return messageDao;
	}
	@Resource(name="messageDao")
	public void setMessageDao(DaoTemplateInterface<Message> messageDao) {
		this.messageDao = messageDao;
	}

	public void add(Message t) throws RunException {
		messageDao.save(t);
	}

	public void removeById(long id) throws RunException {
		messageDao.deleteById(id);
	}

	public void remove(Message t) throws RunException {
		messageDao.delete(t);
	}

	public long update(Message t) throws RunException {
		return messageDao.update(t);
	}

	public Message getById(long id) throws RunException {
		return messageDao.loadById(id);
	}

	public List<Message> getAll() throws RunException {
		return messageDao.loadAll();
	}

}
